<?php
    require("functions.php");
    
    function selectHome($dbname, $dbhandle)
    {
        header('Content-type: application/json');
        
        //echo("Inside getHome lat lng");
        
        $sql ="select * FROM petAmigo.houses where name= 'Home' order by houseid limit 1"; 
        
        //"Select * from Houses where name = 'Home'";
        
        $selected = mysql_select_db($dbname,$dbhandle) 
        or die("Could not select databasename");
        
        $retval = mysql_query( $sql, $dbhandle);
        
        if(! $retval )
        {
          die('Could not get data: ' . mysql_error());
        }
        
        $arr = array();
        //echo(" in the middle Inside getHome lat lng");
        while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
        {
            $arr["name"] = $row["Name"];
            $arr["lat"] = $row["Lat"];
            $arr["lng"] = $row["Lng"];
            
            //echo " ID :{$row['DogId']}  <br> ".
            //     "Name: {$row['Name']} <br> ".
            //     "House id: {$row['HouseId']} <br> ".
            //     "--------------------------------<br>";
        } 
        //echo "Fetched data successfully\n";
        
        echo json_encode($arr);
        //echo json_encode("SendThisData");
    }
    
    selectHome($dbname, $dbhandle);
    closeConnection($dbhandle);
?>